<template>
	<view class="MySettings">
		<view class="MySettingsBox">
			<view class="SettingsList">
				<view class="SettingsItem" @click="topersonalData">
					<view class="SettingsName">个人资料</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
				<view class="SettingsItem" @click="toAccountSecurity">
					<view class="SettingsName">账号与安全</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
				<view class="SettingsItem" @click="noWx">
					<view class="SettingsName">解绑微信</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
				<view class="SettingsItem" @click="toGuide">
					<view class="SettingsName">使用指引</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
				<view class="SettingsItem" @click="toAboutus">
					<view class="SettingsName">关于我们</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
				<view class="SettingsItem" @click="toExplain">
					<view class="SettingsName">投诉与建议</view>
					<u-icon name="arrow-right" color="#BFBFBF" size="25"></u-icon>
				</view>
			</view>
		</view>
		<view class="loginBtn" @click="tologin" v-if="!loginFlag">登录</view>
		<view class="loginBtn" @click="quitLogin" v-if="loginFlag">退出登录</view>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				loginFlag:false
			}
		},
		onShow() {
      // #ifdef APP-PLUS
      var args = plus.runtime.arguments;
      if(args){
        app.$vm.setShareDetail(args);
      }
      // #endif
			if(uni.getStorageSync("rmToken")){
				this.loginFlag = true;
			}else{
				this.loginFlag = false;
			}
		},
		methods: {
			noWx(){
				uni.showModal({
					content:"确定要解绑微信吗?",
					success:res=>{
						console.log(res);
						if(res.confirm){
							this.$u.api.userUnboundWx().then(res=>{
								console.log(res)
								this.$refs.uToast.show({
									title:"解绑成功",
									type:"success",
									duration:2000
								})
							})
						}
					}
				})
			},
			quitLogin(){
				let _this = this;
				uni.showModal({
					content:"确定要退出登录吗?",
					success:res=>{
						if(res.confirm){
							_this.$u.http.setConfig({
								header: {
									'token': ""
								}
							})
							uni.removeStorageSync("rmToken");
							uni.removeStorageSync("userId");
							uni.removeStorageSync("rmUser");
							_this.loginFlag = false;
							app.$vm.globalData.hideFlag = true;
							uni.closeSocket({
								reason:"khdClose"
							})
							_this.$refs.uToast.show({
								title:"已退出登录",
								type:"success",
								duration:2000
							})
						}
					}
				})
				
			},
			//登录
			tologin(){
				// #ifdef MP-WEIXIN
				uni.navigateTo({
					url:"/pages/pagefive/pages/wxLogin/wxLogin"
				})
				// #endif
				// #ifdef APP-PLUS
				uni.navigateTo({
					url:"/pages/pagethree/pages/Login/Login"
				})
				// #endif
				// #ifdef MP-TOUTIAO
				uni.navigateTo({
					url:"/pages/pagethree/pages/Login/Login"
				})
				// #endif
			},
			//关于我们
			toAboutus(){
				uni.navigateTo({
					url:"/pages/pageone/pages/richWeb/richWeb"
				})
			},
			//个人资料
			topersonalData(){
				uni.navigateTo({
					url:"/pages/pagefour/pages/personal-data/personal-data"
				})
			},
			//账号安全
			toAccountSecurity(){
				uni.navigateTo({
					url:"/pages/pageone/pages/AccountSecurity/AccountSecurity"
				})
			},
			toExplain(){
				uni.navigateTo({
					url:"/pages/pagethree/pages/explain/explain"
				})
			},
			toGuide(){
				uni.navigateTo({
					url:"/pages/pagethree/pages/guide/guide"
				})
			},
		}
	}
</script>

<style scoped lang="less">
.status_bar{
	height: var(--status-bar-height);
	width: 100%;
}
.MySettings{
	background-color: #F3F3F3;
	min-height: 100vh;
	// padding-top: 88upx;
	.MySettingsBox{
		padding: 16upx 0;
		.SettingsList{
			.SettingsItem{
				display: flex;
				justify-content: space-between;
				align-items: center;
				width: 750upx;
				background-color: #fff;
				padding: 32upx 24upx;
				border-bottom: 2upx solid #EFEFEF;
				.SettingsName{
					font-size: 28upx;
					font-family: Source Han Sans CN;
					font-weight: 400;
					color: #333333;
				}
			}
		}
	}
	.loginBtn{
		position: fixed;
		bottom: 0;
		width: 750upx;
		height: 100upx;
		background: #FFFFFF;
		opacity: 1;
		font-size: 28upx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		line-height: 100upx;
		text-align: center;
		color: #FFAC3F;
	}
}
</style>
